package annotation;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class Test {
    public static void main(String[] args) throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
        //通过字节码对象，反射类中的所有成员方法
        Class<Demo3> aClass = Demo3.class;
        Demo3 anno = aClass.getConstructor().newInstance();
        Method[] methods = aClass.getMethods();
        for (Method method : methods) {
            //方法上面是否存在注解
            if (method.isAnnotationPresent(MyTest.class)) {
                method.invoke(anno);
            }
        }


    }
}
